//
// Created by haozhenghui on 2020/12/4.
//

#ifndef C_TEST_COMPRESS_H
#define C_TEST_COMPRESS_H

#include "other/bitree.h"

typedef struct {
    unsigned char symbol;
    int freq;
} HuffNode;
typedef struct {
    unsigned char used;
    unsigned short code;
    unsigned char size;
} HuffCode;

int huffman_compress(const unsigned char *original, unsigned char **compressed, int size);

int huffman_uncompress(const unsigned char *compressed, unsigned char **original);

int huffman_test(unsigned char *data, int size);

//lz77
#define LZ77_TYPE_BITS   1
#define LZ77_WINOFF_BITS 12
#define LZ77_BUFLEN_BITS 5
#define LZ77_NEXT_BITS   8

#define LZ77_WINDOW_SIZE 4096
#define LZ77_BUFFER_SIZE 32

#define LZ77_PHRASE_BITS (LZ77_TYPE_BITS+LZ77_WINOFF_BITS+LZ77_NEXT_BITS+LZ77_BUFLEN_BITS)
#define LZ77_SYMBOL_BITS (LZ77_TYPE_BITS+LZ77_NEXT_BITS)

int lz77_compress(const unsigned char *original, unsigned char **compressed, int size);

int lz77_uncompress(const unsigned char *compressed, unsigned char **original);

int lz77_test(unsigned char *data, int size);

#endif //C_TEST_COMPRESS_H
